#引入time时间库
import time
#定义进度条长度为50
scale = 50
print("执行开始".center(scale//2,'-'))
#运用time库perf_counte方法实现获取系统时间
start = time.perf_counter()
#计算进度条走到某一百分比的用时
for i in range(scale+1):
    a = '*' * i
    b = '.' * (scale - i)
    c = (i/scale)*100
    dur = time.perf_counter() - start
#在输出下一个百分比的进度前，停止时长
    print("\r{:^3.0f}%[{}->{}]{:.2f}s".format(c,a,b,dur),end='')
    time.sleep(0.1)
#输出结果
print("\n"+"执行结束".center(scale//2,'-'))
